﻿ Imports MySql.Data.MySqlClient 
 Imports System.Data.OleDb
Imports System.Data.SqlClient
 Imports System .Data .SqlServerCe 
 Imports System.Data.OracleClient 
Imports System.Data
Imports DTO
Public Class LOPHOCDao
Inherits AbstractDao
 #Region "New" 
 Public Sub New(ByVal connection As KetNoiDto)
 MyBase.New(connection)
 End Sub
 Public Sub New( ByVal IDLOPHOC As System.Int32, ByVal connection As KetNoiDto)
 MyBase.New("LOPHOC", "select * from LOPHOC where IDLOPHOC=" & IDLOPHOC & "", connection)
 End Sub
 #End Region 
 Public Sub Them(ByVal Dto As LOPHOCDto)
 Dim strsql As String
 strsql = "Insert into LOPHOC(TENLOP,IDCAPHOC,IDGIANGDAY,NGAYBATKHAIGIANG,NGHIGIUAKY,NGAYKETTHUC,SISO,LOAILOP,TRANGTHAI,GHICHU) values (?,?,?,?,?,?,?,?,?,?)
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 Dim cmd As New OleDbCommand(strsql, Ket_noi_access)
cmd.Parameters.Add("@TENLOP", OleDbType.VarWChar)
cmd.Parameters.Add("@IDCAPHOC", OleDbType.Integer)
cmd.Parameters.Add("@IDGIANGDAY", OleDbType.Integer)
cmd.Parameters.Add("@NGAYBATKHAIGIANG", OleDbType.Date)
cmd.Parameters.Add("@NGHIGIUAKY", OleDbType.Date)
cmd.Parameters.Add("@NGAYKETTHUC", OleDbType.Date)
cmd.Parameters.Add("@SISO", OleDbType.Integer)
cmd.Parameters.Add("@LOAILOP", OleDbType.Integer)
cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
cmd.Parameters("@TENLOP").Value = Dto.TENLOP
cmd.Parameters("@IDCAPHOC").Value = Dto.IDCAPHOC
cmd.Parameters("@IDGIANGDAY").Value = Dto.IDGIANGDAY
cmd.Parameters("@NGAYBATKHAIGIANG").Value = Dto.NGAYBATKHAIGIANG
cmd.Parameters("@NGHIGIUAKY").Value = Dto.NGHIGIUAKY
cmd.Parameters("@NGAYKETTHUC").Value = Dto.NGAYKETTHUC
cmd.Parameters("@SISO").Value = Dto.SISO
cmd.Parameters("@LOAILOP").Value = Dto.LOAILOP
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New OleDbCommand(strsql, Ket_noi_access)
 Dto.IDLOPHOC = cmd.ExecuteScalar()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress
 strsql = "Insert into LOPHOC(TENLOP,IDCAPHOC,IDGIANGDAY,NGAYBATKHAIGIANG,NGHIGIUAKY,NGAYKETTHUC,SISO,LOAILOP,TRANGTHAI,GHICHU) values (@TENLOP,@IDCAPHOC,@IDGIANGDAY,@NGAYBATKHAIGIANG,@NGHIGIUAKY,@NGAYKETTHUC,@SISO,@LOAILOP,@TRANGTHAI,@GHICHU)
 Dim cmd As New sqlCommand(strsql, Ket_noi_sql)
cmd.Parameters.Add("@TENLOP", SqlDbType.NVarChar)
cmd.Parameters.Add("@IDCAPHOC", SqlDbType.Int)
cmd.Parameters.Add("@IDGIANGDAY", SqlDbType.Int)
cmd.Parameters.Add("@NGAYBATKHAIGIANG", SqlDbType.DateTime)
cmd.Parameters.Add("@NGHIGIUAKY", SqlDbType.DateTime)
cmd.Parameters.Add("@NGAYKETTHUC", SqlDbType.DateTime)
cmd.Parameters.Add("@SISO", SqlDbType.Int)
cmd.Parameters.Add("@LOAILOP", SqlDbType.Int)
cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
cmd.Parameters("@TENLOP").Value = Dto.TENLOP
cmd.Parameters("@IDCAPHOC").Value = Dto.IDCAPHOC
cmd.Parameters("@IDGIANGDAY").Value = Dto.IDGIANGDAY
cmd.Parameters("@NGAYBATKHAIGIANG").Value = Dto.NGAYBATKHAIGIANG
cmd.Parameters("@NGHIGIUAKY").Value = Dto.NGHIGIUAKY
cmd.Parameters("@NGAYKETTHUC").Value = Dto.NGAYKETTHUC
cmd.Parameters("@SISO").Value = Dto.SISO
cmd.Parameters("@LOAILOP").Value = Dto.LOAILOP
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New sqlCommand(strsql, Ket_noi_sql)
 Dto.IDLOPHOC = cmd.ExecuteScalar()
 Case Class_KieuDL.SqlCe
 strsql = "Insert into LOPHOC(TENLOP,IDCAPHOC,IDGIANGDAY,NGAYBATKHAIGIANG,NGHIGIUAKY,NGAYKETTHUC,SISO,LOAILOP,TRANGTHAI,GHICHU) values (@TENLOP,@IDCAPHOC,@IDGIANGDAY,@NGAYBATKHAIGIANG,@NGHIGIUAKY,@NGAYKETTHUC,@SISO,@LOAILOP,@TRANGTHAI,@GHICHU)
 Dim cmd As New sqlceCommand(strsql, Ket_noi_SqlCe)
cmd.Parameters("@TENLOP").Value = Dto.TENLOP
cmd.Parameters("@IDCAPHOC").Value = Dto.IDCAPHOC
cmd.Parameters("@IDGIANGDAY").Value = Dto.IDGIANGDAY
cmd.Parameters("@NGAYBATKHAIGIANG").Value = Dto.NGAYBATKHAIGIANG
cmd.Parameters("@NGHIGIUAKY").Value = Dto.NGHIGIUAKY
cmd.Parameters("@NGAYKETTHUC").Value = Dto.NGAYKETTHUC
cmd.Parameters("@SISO").Value = Dto.SISO
cmd.Parameters("@LOAILOP").Value = Dto.LOAILOP
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strsql = "Insert into LOPHOC(TENLOP,IDCAPHOC,IDGIANGDAY,NGAYBATKHAIGIANG,NGHIGIUAKY,NGAYKETTHUC,SISO,LOAILOP,TRANGTHAI,GHICHU) values (@TENLOP,@IDCAPHOC,@IDGIANGDAY,@NGAYBATKHAIGIANG,@NGHIGIUAKY,@NGAYKETTHUC,@SISO,@LOAILOP,@TRANGTHAI,@GHICHU)
 Dim cmd As New OracleCommand(strsql, Ket_noi_Oracle)
cmd.Parameters("@TENLOP").Value = Dto.TENLOP
cmd.Parameters("@IDCAPHOC").Value = Dto.IDCAPHOC
cmd.Parameters("@IDGIANGDAY").Value = Dto.IDGIANGDAY
cmd.Parameters("@NGAYBATKHAIGIANG").Value = Dto.NGAYBATKHAIGIANG
cmd.Parameters("@NGHIGIUAKY").Value = Dto.NGHIGIUAKY
cmd.Parameters("@NGAYKETTHUC").Value = Dto.NGAYKETTHUC
cmd.Parameters("@SISO").Value = Dto.SISO
cmd.Parameters("@LOAILOP").Value = Dto.LOAILOP
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Mysql
 strsql = "Insert into LOPHOC(TENLOP,IDCAPHOC,IDGIANGDAY,NGAYBATKHAIGIANG,NGHIGIUAKY,NGAYKETTHUC,SISO,LOAILOP,TRANGTHAI,GHICHU) values (@TENLOP,@IDCAPHOC,@IDGIANGDAY,@NGAYBATKHAIGIANG,@NGHIGIUAKY,@NGAYKETTHUC,@SISO,@LOAILOP,@TRANGTHAI,@GHICHU)
 Dim cmd As New MySqlCommand(strsql, Ket_noi_MySql)
cmd.Parameters.Add("@TENLOP", MySqlDbType.String)
cmd.Parameters.Add("@IDCAPHOC", MySqlDbType.Int32)
cmd.Parameters.Add("@IDGIANGDAY", MySqlDbType.Int32)
cmd.Parameters.Add("@NGAYBATKHAIGIANG",  MySqlDbType.DateTime)
cmd.Parameters.Add("@NGHIGIUAKY",  MySqlDbType.DateTime)
cmd.Parameters.Add("@NGAYKETTHUC",  MySqlDbType.DateTime)
cmd.Parameters.Add("@SISO", MySqlDbType.Int32)
cmd.Parameters.Add("@LOAILOP", MySqlDbType.Int32)
cmd.Parameters.Add("@TRANGTHAI", MySqlDbType.Int32)
cmd.Parameters.Add("@GHICHU", MySqlDbType.String)
cmd.Parameters("@TENLOP").Value = Dto.TENLOP
cmd.Parameters("@IDCAPHOC").Value = Dto.IDCAPHOC
cmd.Parameters("@IDGIANGDAY").Value = Dto.IDGIANGDAY
cmd.Parameters("@NGAYBATKHAIGIANG").Value = Dto.NGAYBATKHAIGIANG
cmd.Parameters("@NGHIGIUAKY").Value = Dto.NGHIGIUAKY
cmd.Parameters("@NGAYKETTHUC").Value = Dto.NGAYKETTHUC
cmd.Parameters("@SISO").Value = Dto.SISO
cmd.Parameters("@LOAILOP").Value = Dto.LOAILOP
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub Xoa( ByVal IDLOPHOC As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
strSQL = "Delete From LOPHOC Where IDLOPHOC= ? 
Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@IDLOPHOC",OleDbType.Integer).Value = IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
strSQL = "Delete From LOPHOC Where IDLOPHOC= @IDLOPHOC
Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@IDLOPHOC",SqlDbType.Int).value=IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
strSQL = "Delete From LOPHOC Where IDLOPHOC=" & IDLOPHOC & "
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
strSQL = "Delete From LOPHOC Where IDLOPHOC=" & IDLOPHOC & "
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
strSQL = "Delete From LOPHOC Where IDLOPHOC=" & IDLOPHOC & "
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub sua(ByVal dto As LOPHOCDto)
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update LOPHOC Set TENLOP=? ,IDCAPHOC=? ,IDGIANGDAY=? ,NGAYBATKHAIGIANG=? ,NGHIGIUAKY=? ,NGAYKETTHUC=? ,SISO=? ,LOAILOP=? ,TRANGTHAI=? ,GHICHU= ? where IDLOPHOC= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@TENLOP", OleDbType.VarWChar)
cmd.Parameters.Add("@IDCAPHOC", OleDbType.Integer)
cmd.Parameters.Add("@IDGIANGDAY", OleDbType.Integer)
cmd.Parameters.Add("@NGAYBATKHAIGIANG", OleDbType.Date)
cmd.Parameters.Add("@NGHIGIUAKY", OleDbType.Date)
cmd.Parameters.Add("@NGAYKETTHUC", OleDbType.Date)
cmd.Parameters.Add("@SISO", OleDbType.Integer)
cmd.Parameters.Add("@LOAILOP", OleDbType.Integer)
cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
cmd.Parameters("@TENLOP").Value = dto.TENLOP
cmd.Parameters("@IDCAPHOC").Value = dto.IDCAPHOC
cmd.Parameters("@IDGIANGDAY").Value = dto.IDGIANGDAY
cmd.Parameters("@NGAYBATKHAIGIANG").Value = dto.NGAYBATKHAIGIANG
cmd.Parameters("@NGHIGIUAKY").Value = dto.NGHIGIUAKY
cmd.Parameters("@NGAYKETTHUC").Value = dto.NGAYKETTHUC
cmd.Parameters("@SISO").Value = dto.SISO
cmd.Parameters("@LOAILOP").Value = dto.LOAILOP
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update LOPHOC Set TENLOP= @TENLOP , IDCAPHOC= @IDCAPHOC , IDGIANGDAY= @IDGIANGDAY , NGAYBATKHAIGIANG= @NGAYBATKHAIGIANG , NGHIGIUAKY= @NGHIGIUAKY , NGAYKETTHUC= @NGAYKETTHUC , SISO= @SISO , LOAILOP= @LOAILOP , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@TENLOP", SqlDbType.NVarChar)
cmd.Parameters.Add("@IDCAPHOC", SqlDbType.Int)
cmd.Parameters.Add("@IDGIANGDAY", SqlDbType.Int)
cmd.Parameters.Add("@NGAYBATKHAIGIANG", SqlDbType.DateTime)
cmd.Parameters.Add("@NGHIGIUAKY", SqlDbType.DateTime)
cmd.Parameters.Add("@NGAYKETTHUC", SqlDbType.DateTime)
cmd.Parameters.Add("@SISO", SqlDbType.Int)
cmd.Parameters.Add("@LOAILOP", SqlDbType.Int)
cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
cmd.Parameters("@TENLOP").Value = dto.TENLOP
cmd.Parameters("@IDCAPHOC").Value = dto.IDCAPHOC
cmd.Parameters("@IDGIANGDAY").Value = dto.IDGIANGDAY
cmd.Parameters("@NGAYBATKHAIGIANG").Value = dto.NGAYBATKHAIGIANG
cmd.Parameters("@NGHIGIUAKY").Value = dto.NGHIGIUAKY
cmd.Parameters("@NGAYKETTHUC").Value = dto.NGAYKETTHUC
cmd.Parameters("@SISO").Value = dto.SISO
cmd.Parameters("@LOAILOP").Value = dto.LOAILOP
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update LOPHOC Set TENLOP= @TENLOP , IDCAPHOC= @IDCAPHOC , IDGIANGDAY= @IDGIANGDAY , NGAYBATKHAIGIANG= @NGAYBATKHAIGIANG , NGHIGIUAKY= @NGHIGIUAKY , NGAYKETTHUC= @NGAYKETTHUC , SISO= @SISO , LOAILOP= @LOAILOP , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
cmd.Parameters("@TENLOP").Value = dto.TENLOP
cmd.Parameters("@IDCAPHOC").Value = dto.IDCAPHOC
cmd.Parameters("@IDGIANGDAY").Value = dto.IDGIANGDAY
cmd.Parameters("@NGAYBATKHAIGIANG").Value = dto.NGAYBATKHAIGIANG
cmd.Parameters("@NGHIGIUAKY").Value = dto.NGHIGIUAKY
cmd.Parameters("@NGAYKETTHUC").Value = dto.NGAYKETTHUC
cmd.Parameters("@SISO").Value = dto.SISO
cmd.Parameters("@LOAILOP").Value = dto.LOAILOP
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update LOPHOC Set TENLOP= @TENLOP , IDCAPHOC= @IDCAPHOC , IDGIANGDAY= @IDGIANGDAY , NGAYBATKHAIGIANG= @NGAYBATKHAIGIANG , NGHIGIUAKY= @NGHIGIUAKY , NGAYKETTHUC= @NGAYKETTHUC , SISO= @SISO , LOAILOP= @LOAILOP , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
cmd.Parameters("@TENLOP").Value = dto.TENLOP
cmd.Parameters("@IDCAPHOC").Value = dto.IDCAPHOC
cmd.Parameters("@IDGIANGDAY").Value = dto.IDGIANGDAY
cmd.Parameters("@NGAYBATKHAIGIANG").Value = dto.NGAYBATKHAIGIANG
cmd.Parameters("@NGHIGIUAKY").Value = dto.NGHIGIUAKY
cmd.Parameters("@NGAYKETTHUC").Value = dto.NGAYKETTHUC
cmd.Parameters("@SISO").Value = dto.SISO
cmd.Parameters("@LOAILOP").Value = dto.LOAILOP
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update LOPHOC Set TENLOP= @TENLOP , IDCAPHOC= @IDCAPHOC , IDGIANGDAY= @IDGIANGDAY , NGAYBATKHAIGIANG= @NGAYBATKHAIGIANG , NGHIGIUAKY= @NGHIGIUAKY , NGAYKETTHUC= @NGAYKETTHUC , SISO= @SISO , LOAILOP= @LOAILOP , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
cmd.Parameters.Add("@TENLOP", MySqlDbType.String)
cmd.Parameters.Add("@IDCAPHOC", MySqlDbType.Int32)
cmd.Parameters.Add("@IDGIANGDAY", MySqlDbType.Int32)
cmd.Parameters.Add("@NGAYBATKHAIGIANG",  MySqlDbType.DateTime)
cmd.Parameters.Add("@NGHIGIUAKY",  MySqlDbType.DateTime)
cmd.Parameters.Add("@NGAYKETTHUC",  MySqlDbType.DateTime)
cmd.Parameters.Add("@SISO", MySqlDbType.Int32)
cmd.Parameters.Add("@LOAILOP", MySqlDbType.Int32)
cmd.Parameters.Add("@TRANGTHAI", MySqlDbType.Int32)
cmd.Parameters.Add("@GHICHU", MySqlDbType.String)
cmd.Parameters.Add("@IDLOPHOC", MySqlDbType.Int32)
cmd.Parameters("@TENLOP").Value = dto.TENLOP
cmd.Parameters("@IDCAPHOC").Value = dto.IDCAPHOC
cmd.Parameters("@IDGIANGDAY").Value = dto.IDGIANGDAY
cmd.Parameters("@NGAYBATKHAIGIANG").Value = dto.NGAYBATKHAIGIANG
cmd.Parameters("@NGHIGIUAKY").Value = dto.NGHIGIUAKY
cmd.Parameters("@NGAYKETTHUC").Value = dto.NGAYKETTHUC
cmd.Parameters("@SISO").Value = dto.SISO
cmd.Parameters("@LOAILOP").Value = dto.LOAILOP
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub SuaTENLOP( ByVal TENLOP as System.String, ByVal IDLOPHOC As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update LOPHOC Set TENLOP = ?  where IDLOPHOC= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@TENLOP", OleDbType.VarWChar)
 cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
 cmd.Parameters("@TENLOP").Value =  TENLOP
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update LOPHOC Set TENLOP = @TENLOP  where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@TENLOP", SqlDbType.NVarChar)
 cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
 cmd.Parameters("@TENLOP").Value =  TENLOP
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update LOPHOC Set TENLOP =" & TENLOP & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update LOPHOC Set TENLOP =" & TENLOP & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update LOPHOC Set TENLOP =" & TENLOP & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaIDCAPHOC( ByVal IDCAPHOC as System.Int32, ByVal IDLOPHOC As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update LOPHOC Set IDCAPHOC = ?  where IDLOPHOC= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@IDCAPHOC", OleDbType.Integer)
 cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
 cmd.Parameters("@IDCAPHOC").Value =  IDCAPHOC
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update LOPHOC Set IDCAPHOC = @IDCAPHOC  where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@IDCAPHOC", SqlDbType.Int)
 cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
 cmd.Parameters("@IDCAPHOC").Value =  IDCAPHOC
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update LOPHOC Set IDCAPHOC =" & IDCAPHOC & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update LOPHOC Set IDCAPHOC =" & IDCAPHOC & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update LOPHOC Set IDCAPHOC =" & IDCAPHOC & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaIDGIANGDAY( ByVal IDGIANGDAY as System.Int32, ByVal IDLOPHOC As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update LOPHOC Set IDGIANGDAY = ?  where IDLOPHOC= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@IDGIANGDAY", OleDbType.Integer)
 cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
 cmd.Parameters("@IDGIANGDAY").Value =  IDGIANGDAY
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update LOPHOC Set IDGIANGDAY = @IDGIANGDAY  where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@IDGIANGDAY", SqlDbType.Int)
 cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
 cmd.Parameters("@IDGIANGDAY").Value =  IDGIANGDAY
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update LOPHOC Set IDGIANGDAY =" & IDGIANGDAY & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update LOPHOC Set IDGIANGDAY =" & IDGIANGDAY & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update LOPHOC Set IDGIANGDAY =" & IDGIANGDAY & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaNGAYBATKHAIGIANG( ByVal NGAYBATKHAIGIANG as System.DateTime, ByVal IDLOPHOC As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update LOPHOC Set NGAYBATKHAIGIANG = ?  where IDLOPHOC= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@NGAYBATKHAIGIANG", OleDbType.Date)
 cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
 cmd.Parameters("@NGAYBATKHAIGIANG").Value =  NGAYBATKHAIGIANG
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update LOPHOC Set NGAYBATKHAIGIANG = @NGAYBATKHAIGIANG  where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@NGAYBATKHAIGIANG", SqlDbType.DateTime)
 cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
 cmd.Parameters("@NGAYBATKHAIGIANG").Value =  NGAYBATKHAIGIANG
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update LOPHOC Set NGAYBATKHAIGIANG =" & NGAYBATKHAIGIANG & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update LOPHOC Set NGAYBATKHAIGIANG =" & NGAYBATKHAIGIANG & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update LOPHOC Set NGAYBATKHAIGIANG =" & NGAYBATKHAIGIANG & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaNGHIGIUAKY( ByVal NGHIGIUAKY as System.DateTime, ByVal IDLOPHOC As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update LOPHOC Set NGHIGIUAKY = ?  where IDLOPHOC= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@NGHIGIUAKY", OleDbType.Date)
 cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
 cmd.Parameters("@NGHIGIUAKY").Value =  NGHIGIUAKY
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update LOPHOC Set NGHIGIUAKY = @NGHIGIUAKY  where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@NGHIGIUAKY", SqlDbType.DateTime)
 cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
 cmd.Parameters("@NGHIGIUAKY").Value =  NGHIGIUAKY
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update LOPHOC Set NGHIGIUAKY =" & NGHIGIUAKY & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update LOPHOC Set NGHIGIUAKY =" & NGHIGIUAKY & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update LOPHOC Set NGHIGIUAKY =" & NGHIGIUAKY & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaNGAYKETTHUC( ByVal NGAYKETTHUC as System.DateTime, ByVal IDLOPHOC As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update LOPHOC Set NGAYKETTHUC = ?  where IDLOPHOC= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@NGAYKETTHUC", OleDbType.Date)
 cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
 cmd.Parameters("@NGAYKETTHUC").Value =  NGAYKETTHUC
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update LOPHOC Set NGAYKETTHUC = @NGAYKETTHUC  where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@NGAYKETTHUC", SqlDbType.DateTime)
 cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
 cmd.Parameters("@NGAYKETTHUC").Value =  NGAYKETTHUC
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update LOPHOC Set NGAYKETTHUC =" & NGAYKETTHUC & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update LOPHOC Set NGAYKETTHUC =" & NGAYKETTHUC & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update LOPHOC Set NGAYKETTHUC =" & NGAYKETTHUC & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaSISO( ByVal SISO as System.Int32, ByVal IDLOPHOC As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update LOPHOC Set SISO = ?  where IDLOPHOC= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@SISO", OleDbType.Integer)
 cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
 cmd.Parameters("@SISO").Value =  SISO
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update LOPHOC Set SISO = @SISO  where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@SISO", SqlDbType.Int)
 cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
 cmd.Parameters("@SISO").Value =  SISO
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update LOPHOC Set SISO =" & SISO & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update LOPHOC Set SISO =" & SISO & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update LOPHOC Set SISO =" & SISO & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaLOAILOP( ByVal LOAILOP as System.Int32, ByVal IDLOPHOC As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update LOPHOC Set LOAILOP = ?  where IDLOPHOC= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@LOAILOP", OleDbType.Integer)
 cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
 cmd.Parameters("@LOAILOP").Value =  LOAILOP
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update LOPHOC Set LOAILOP = @LOAILOP  where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@LOAILOP", SqlDbType.Int)
 cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
 cmd.Parameters("@LOAILOP").Value =  LOAILOP
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update LOPHOC Set LOAILOP =" & LOAILOP & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update LOPHOC Set LOAILOP =" & LOAILOP & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update LOPHOC Set LOAILOP =" & LOAILOP & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDLOPHOC As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update LOPHOC Set TRANGTHAI = ?  where IDLOPHOC= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
 cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
 cmd.Parameters("@TRANGTHAI").Value =  TRANGTHAI
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update LOPHOC Set TRANGTHAI = @TRANGTHAI  where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
 cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
 cmd.Parameters("@TRANGTHAI").Value =  TRANGTHAI
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update LOPHOC Set TRANGTHAI =" & TRANGTHAI & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update LOPHOC Set TRANGTHAI =" & TRANGTHAI & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update LOPHOC Set TRANGTHAI =" & TRANGTHAI & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaGHICHU( ByVal GHICHU as System.String, ByVal IDLOPHOC As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update LOPHOC Set GHICHU = ?  where IDLOPHOC= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
 cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
 cmd.Parameters("@GHICHU").Value =  GHICHU
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update LOPHOC Set GHICHU = @GHICHU  where IDLOPHOC= @IDLOPHOC"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
 cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
 cmd.Parameters("@GHICHU").Value =  GHICHU
cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update LOPHOC Set GHICHU =" & GHICHU & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update LOPHOC Set GHICHU =" & GHICHU & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update LOPHOC Set GHICHU =" & GHICHU & "  where IDLOPHOC=" & IDLOPHOC & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub layBang()
 Chuoi_SQL = " Select * from LOPHOC
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDLOPHOC(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDLOPHOC=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from LOPHOC" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDLOPHOC(ByVal IDLOPHOC As System.Int32 )
        Chuoi_SQL = " Select IDLOPHOC ,TENLOP ,IDCAPHOC ,IDGIANGDAY ,NGAYBATKHAIGIANG ,NGHIGIUAKY ,NGAYKETTHUC ,SISO ,case  when LOAILOP = 1 then N'LỚP THƯỜNG' ELSE N'LỚP CHUYÊN'  end  as 'LOAILOP' from LOPHOC where  IDLOPHOC = " & IDLOPHOC & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDLOPHOC(ByVal IDLOPHOC As System.Int32)
 Dim strsql As String
 strSQL = "Delete From LOPHOC Where IDLOPHOC=" & IDLOPHOC & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoTENLOP(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "TENLOP='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from LOPHOC" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoTENLOP_like (ByVal TENLOP As System.String )
 Chuoi_SQL = " Select * from LOPHOC where  TENLOP  like '%" & TENLOP & "%'"
 Doc_bang()
 End Sub
 Public Sub layBangTheoTENLOP(ByVal TENLOP As System.String )
 Chuoi_SQL = " Select * from LOPHOC where  TENLOP = '" & TENLOP & "'"
 Doc_bang()
 End Sub
 Public Sub XOABangTheoTENLOP(ByVal TENLOP As System.String)
 Dim strsql As String
 strSQL = "Delete From LOPHOC Where TENLOP='" & TENLOP & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoIDCAPHOC(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDCAPHOC=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from LOPHOC" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDCAPHOC(ByVal IDCAPHOC As System.Int32 )
 Chuoi_SQL = " Select * from LOPHOC where  IDCAPHOC = " & IDCAPHOC & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDCAPHOC(ByVal IDCAPHOC As System.Int32)
 Dim strsql As String
 strSQL = "Delete From LOPHOC Where IDCAPHOC=" & IDCAPHOC & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoIDGIANGDAY(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDGIANGDAY=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from LOPHOC" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDGIANGDAY(ByVal IDGIANGDAY As System.Int32 )
 Chuoi_SQL = " Select * from LOPHOC where  IDGIANGDAY = " & IDGIANGDAY & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDGIANGDAY(ByVal IDGIANGDAY As System.Int32)
 Dim strsql As String
 strSQL = "Delete From LOPHOC Where IDGIANGDAY=" & IDGIANGDAY & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoNGAYBATKHAIGIANG(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "NGAYBATKHAIGIANG='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from LOPHOC" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoNGAYBATKHAIGIANG(ByVal NGAYBATKHAIGIANG As System.DateTime )
 Chuoi_SQL = " Select * from LOPHOC where  NGAYBATKHAIGIANG = @Ngay
 Doc_bang_Dk_ngay(NGAYBATKHAIGIANG)
 End Sub
 Public Sub layBangTheoNGAYBATKHAIGIANG(ByVal NGAYBATKHAIGIANG1 As System.DateTime,ByVal NGAYBATKHAIGIANG2 As System.DateTime )
 Chuoi_SQL = " Select * from LOPHOC where  NGAYBATKHAIGIANG >= @Ngay and NGAYBATKHAIGIANG <= @denNgay ORDER BY NGAYBATKHAIGIANG
 Doc_bang_Dk_ngay(NGAYBATKHAIGIANG1,NGAYBATKHAIGIANG2)
 End Sub
 Public Sub XOABangTheoNGAYBATKHAIGIANG(ByVal NGAYBATKHAIGIANG As System.DateTime)
 Dim strsql As String
 strSQL = "Delete From LOPHOC Where NGAYBATKHAIGIANG='" & NGAYBATKHAIGIANG & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoNGHIGIUAKY(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "NGHIGIUAKY='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from LOPHOC" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoNGHIGIUAKY(ByVal NGHIGIUAKY As System.DateTime )
 Chuoi_SQL = " Select * from LOPHOC where  NGHIGIUAKY = @Ngay
 Doc_bang_Dk_ngay(NGHIGIUAKY)
 End Sub
 Public Sub layBangTheoNGHIGIUAKY(ByVal NGHIGIUAKY1 As System.DateTime,ByVal NGHIGIUAKY2 As System.DateTime )
 Chuoi_SQL = " Select * from LOPHOC where  NGHIGIUAKY >= @Ngay and NGHIGIUAKY <= @denNgay ORDER BY NGHIGIUAKY
 Doc_bang_Dk_ngay(NGHIGIUAKY1,NGHIGIUAKY2)
 End Sub
 Public Sub XOABangTheoNGHIGIUAKY(ByVal NGHIGIUAKY As System.DateTime)
 Dim strsql As String
 strSQL = "Delete From LOPHOC Where NGHIGIUAKY='" & NGHIGIUAKY & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoNGAYKETTHUC(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "NGAYKETTHUC='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from LOPHOC" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoNGAYKETTHUC(ByVal NGAYKETTHUC As System.DateTime )
 Chuoi_SQL = " Select * from LOPHOC where  NGAYKETTHUC = @Ngay
 Doc_bang_Dk_ngay(NGAYKETTHUC)
 End Sub
 Public Sub layBangTheoNGAYKETTHUC(ByVal NGAYKETTHUC1 As System.DateTime,ByVal NGAYKETTHUC2 As System.DateTime )
 Chuoi_SQL = " Select * from LOPHOC where  NGAYKETTHUC >= @Ngay and NGAYKETTHUC <= @denNgay ORDER BY NGAYKETTHUC
 Doc_bang_Dk_ngay(NGAYKETTHUC1,NGAYKETTHUC2)
 End Sub
 Public Sub XOABangTheoNGAYKETTHUC(ByVal NGAYKETTHUC As System.DateTime)
 Dim strsql As String
 strSQL = "Delete From LOPHOC Where NGAYKETTHUC='" & NGAYKETTHUC & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoSISO(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "SISO=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from LOPHOC" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoSISO(ByVal SISO As System.Int32 )
 Chuoi_SQL = " Select * from LOPHOC where  SISO = " & SISO & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoSISO(ByVal SISO As System.Int32)
 Dim strsql As String
 strSQL = "Delete From LOPHOC Where SISO=" & SISO & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoLOAILOP(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "LOAILOP=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from LOPHOC" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoLOAILOP(ByVal LOAILOP As System.Int32 )
        Chuoi_SQL = " Select  IDLOPHOC ,TENLOP ,IDCAPHOC ,IDGIANGDAY ,NGAYBATKHAIGIANG ,NGHIGIUAKY ,NGAYKETTHUC ,SISO ,case  when LOAILOP = 1 then N'LỚP THƯỜNG' ELSE N'LỚP CHUYÊN'  end  as 'LOAILOP' from LOPHOC where  LOAILOP = " & LOAILOP & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoLOAILOP(ByVal LOAILOP As System.Int32)
 Dim strsql As String
 strSQL = "Delete From LOPHOC Where LOAILOP=" & LOAILOP & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoTRANGTHAI(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "TRANGTHAI=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from LOPHOC" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoTRANGTHAI(ByVal TRANGTHAI As System.Int32 )
 Chuoi_SQL = " Select * from LOPHOC where  TRANGTHAI = " & TRANGTHAI & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoTRANGTHAI(ByVal TRANGTHAI As System.Int32)
 Dim strsql As String
 strSQL = "Delete From LOPHOC Where TRANGTHAI=" & TRANGTHAI & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoGHICHU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "GHICHU='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from LOPHOC" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoGHICHU_like (ByVal GHICHU As System.String )
 Chuoi_SQL = " Select * from LOPHOC where  GHICHU  like '%" & GHICHU & "%'"
 Doc_bang()
 End Sub
 Public Sub layBangTheoGHICHU(ByVal GHICHU As System.String )
 Chuoi_SQL = " Select * from LOPHOC where  GHICHU = '" & GHICHU & "'"
 Doc_bang()
 End Sub
 Public Sub XOABangTheoGHICHU(ByVal GHICHU As System.String)
 Dim strsql As String
 strSQL = "Delete From LOPHOC Where GHICHU='" & GHICHU & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangNhieuTable
        Chuoi_SQL = " Select IDLOPHOC ,TENLOP ,IDCAPHOC ,IDGIANGDAY ,NGAYBATKHAIGIANG ,NGHIGIUAKY ,NGAYKETTHUC ,SISO ,case  when LOAILOP = 1 then N'LỚP THƯỜNG' ELSE N'LỚP CHUYÊN'  end  as 'LOAILOP' ,TRANGTHAI ,GHICHU  from LOPHOC"
 Doc_bang()
 End sub
Public Sub TaoTable()
Dim strsql As String
strsql = ""
Select Case ketnoi.MsSql
Case Class_KieuDL.Access 
Case Class_KieuDL.Sql, Class_KieuDL.sqlExpress
strsql = ""
Case Class_KieuDL.SqlCe
strsql = ""
Case Class_KieuDL.Oracle
strsql = ""
Case else 
strsql = ""
End Select
Thuc_hien_lenh(strsql)
    End Sub
#Region "viet"
    Public Sub laybangthaotrangthai_cap(ByVal caphoc As System.Int32, ByVal loai As System.Int32)
        Chuoi_SQL = " Select IDLOPHOC ,TENLOP ,IDCAPHOC ,IDGIANGDAY ,NGAYBATKHAIGIANG ,NGHIGIUAKY ,NGAYKETTHUC ,SISO  ,TRANGTHAI ,GHICHU,case  when LOAILOP = 1 then N'LỚP THƯỜNG' ELSE N'LỚP CHUYÊN'  end  as 'LOAILOP' from LOPHOC where  IDCAPHOC = " & caphoc & " and LOAILOP = " & loai
        Doc_bang()
    End Sub
#End Region
 End Class

